<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/5/6
  Time: 16:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<html>
<head>
    <title>Title</title>
</head>
<body>
<table>
    <thead>
    <tr>
        <th>编号</th>
        <th>用户名</th>
        <th>密码</th>
        <th colspan="2">操作</th>
    </tr>
    </thead>
    <tbody id="tbody">

    </tbody>
    <%--<c:forEach items="${list}" var="l">
        <tr>
            <td>${l.col_Id}</td>
            <td>${l.col_Name}</td>
            <td>${l.col_Pwd}</td>
            <td>
                <button id="del" onclick="erq(${l.col_Id})">删除</button>
            </td>
            <td><input type="button" id="upd" value="修改" onclick="qwe(${l.col_Id})"/></td>
        </tr>
    </c:forEach>--%>
    <tfoot>
    <tr>
        <th colspan="4"><a href="addAdmin.jsp">添加管理员</a></th>
    </tr>
    </tfoot>

</table>
</body>
<script>

    $(function () {

        $.ajax({
            url: "allUser_show",
            type: "POST",
            dataType: "json",
            success: function (data) {
                var $tbody = $("#tbody").html("");
                var str = "";
                $(data).each(function (i, n) {
                    str += " <tr>" +
                        "<td>" + n.col_Id + "</td>" +
                        "<td>" + n.col_Name + "</td>" +
                        "<td>" + n.col_Pwd + "</td>" +
                        "<td><button class='del' onclick='qwe(" + n.col_Id + ")'>删除</button></td>" +
                        "<td><button class='upd' onclick='wer(" + n.col_Id + ")'>修改</button></td>" +
                        "</tr>"
                })
                $tbody.append(str)
            }
        })


                $(".del").live("click", function () {
                    var id = $(this).parent().parent().children("td").eq(0).html();
                    location = "allUser_del?id="+id;
                });

                $(".upd").live("click", function () {
                    var id = $(this).parent().parent().children("td").eq(0).html();
                    location = "allUser_updf?id="+id;
                });
            });

/*        function qwe(id) {
            location = "allUser_del?id=" + id;
        }

        function wer(id) {
            location = "allUser_updf?id=" + id;
    }*/
</script>

</html>
